package com.octoplay;

import java.util.ArrayList;
import java.util.HashMap;

import android.app.Activity;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.octoplay.octoshape.Stream;

public class OctoDemoActivity extends ListActivity {
	public static final String LOGTAG = "OctoDemoPlayer";
	private final String[] STREAM_LINKS = {
			"octoshape://streams.octoshape.net/Demo.NBA_500?protocol=v310",
			"octoshape://streams.octoshape.net/androidsdk/mp4/bbb?protocol=v310",
			"octoshape://streams.octoshape.net/androidsdk/mp4/nascar_500?protocol=v310",
			"octoshape://streams.octoshape.net/SMOOTHLOUNGE.smoothlounge_mp3?protocol=v310",
			"octoshape://streams.octoshape.net/SMOOTHLOUNGE.smoothjazz_mp3?protocol=v310",
			"octoshape://ond.octoshape.com/makholm/snurresnup?protocol=v310" };
	private final String[] STREAM_NAMES = { "LIVE - NBA 500kb (rtmp)",
			"OND - Big Buck Bunny - 1.8mb (mp4)", "OND - Nascar 500 (FLV)",
			"RADIO - Smooth Lounge (mp3)",
			"RADIO - Smooth Jazz with DVR (mp3)", "OND - snurresnup (mp3)" };

	private HashMap<String, Stream> streams = new HashMap<String, Stream>();

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		ArrayAdapter<String> adp = new ArrayAdapter<String>(this,
				android.R.layout.simple_list_item_1, android.R.id.text1,
				STREAM_NAMES);
		getListView().setAdapter(adp);
		getListView().setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				startActivity(new Intent(OctoDemoActivity.this, OctoPlayerActivity.class).putExtra("link", STREAM_LINKS[position]));
			}
		});
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.activity_main, menu);
		return true;
	}

}
